﻿using System;
using System.Text;
using Mono.Cecil.Cil;
using Mono.Cecil.Metadata;
using Mono.Cecil.PE;
using Mono.Collections.Generic;

namespace Mono.Cecil
{
	// Token: 0x02000022 RID: 34
	internal sealed class SignatureReader : ByteBuffer
	{
		// Token: 0x1700003A RID: 58
		// (get) Token: 0x06000213 RID: 531 RVA: 0x00012F10 File Offset: 0x00011110
		private TypeSystem TypeSystem
		{
			get
			{
				return this.reader.module.TypeSystem;
			}
		}

		// Token: 0x06000214 RID: 532 RVA: 0x0000301E File Offset: 0x0000121E
		public SignatureReader(uint blob, MetadataReader reader) : base(reader.image.BlobHeap.data)
		{
			this.reader = reader;
			this.position = (int)blob;
			this.sig_length = base.ReadCompressedUInt32();
			this.start = (uint)this.position;
		}

		// Token: 0x06000215 RID: 533 RVA: 0x00012F34 File Offset: 0x00011134
		private MetadataToken ReadTypeTokenSignature()
		{
			return CodedIndex.TypeDefOrRef.GetMetadataToken(base.ReadCompressedUInt32());
		}

		// Token: 0x06000216 RID: 534 RVA: 0x00012F54 File Offset: 0x00011154
		private GenericParameter GetGenericParameter(GenericParameterType type, uint var)
		{
			IGenericContext context = this.reader.context;
			bool flag = context == null;
			GenericParameter result;
			if (flag)
			{
				result = this.GetUnboundGenericParameter(type, (int)var);
			}
			else
			{
				IGenericParameterProvider genericParameterProvider;
				if (type != GenericParameterType.Type)
				{
					if (type != GenericParameterType.Method)
					{
						throw new NotSupportedException();
					}
					genericParameterProvider = context.Method;
				}
				else
				{
					genericParameterProvider = context.Type;
				}
				bool flag2 = !context.IsDefinition;
				if (flag2)
				{
					SignatureReader.CheckGenericContext(genericParameterProvider, (int)var);
				}
				bool flag3 = var >= (uint)genericParameterProvider.GenericParameters.Count;
				if (flag3)
				{
					result = this.GetUnboundGenericParameter(type, (int)var);
				}
				else
				{
					result = genericParameterProvider.GenericParameters[(int)var];
				}
			}
			return result;
		}

		// Token: 0x06000217 RID: 535 RVA: 0x00012FFC File Offset: 0x000111FC
		private GenericParameter GetUnboundGenericParameter(GenericParameterType type, int index)
		{
			return new GenericParameter(index, type, this.reader.module);
		}

		// Token: 0x06000218 RID: 536 RVA: 0x00013020 File Offset: 0x00011220
		private static void CheckGenericContext(IGenericParameterProvider owner, int index)
		{
			Collection<GenericParameter> genericParameters = owner.GenericParameters;
			for (int i = genericParameters.Count; i <= index; i++)
			{
				genericParameters.Add(new GenericParameter(owner));
			}
		}

		// Token: 0x06000219 RID: 537 RVA: 0x0001305C File Offset: 0x0001125C
		public void ReadGenericInstanceSignature(IGenericParameterProvider provider, IGenericInstance instance, uint arity)
		{
			bool flag = !provider.IsDefinition;
			if (flag)
			{
				SignatureReader.CheckGenericContext(provider, (int)(arity - 1U));
			}
			Collection<TypeReference> genericArguments = instance.GenericArguments;
			int num = 0;
			while ((long)num < (long)((ulong)arity))
			{
				genericArguments.Add(this.ReadTypeSignature());
				num++;
			}
		}

		// Token: 0x0600021A RID: 538 RVA: 0x000130A8 File Offset: 0x000112A8
		private ArrayType ReadArrayTypeSignature()
		{
			ArrayType arrayType = new ArrayType(this.ReadTypeSignature());
			uint num = base.ReadCompressedUInt32();
			uint[] array = new uint[base.ReadCompressedUInt32()];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = base.ReadCompressedUInt32();
			}
			int[] array2 = new int[base.ReadCompressedUInt32()];
			for (int j = 0; j < array2.Length; j++)
			{
				array2[j] = base.ReadCompressedInt32();
			}
			arrayType.Dimensions.Clear();
			int num2 = 0;
			while ((long)num2 < (long)((ulong)num))
			{
				int? num3 = null;
				int? upperBound = null;
				bool flag = num2 < array2.Length;
				if (flag)
				{
					num3 = new int?(array2[num2]);
				}
				bool flag2 = num2 < array.Length;
				if (flag2)
				{
					int? num4 = num3;
					int num5 = (int)array[num2];
					upperBound = ((num4 != null) ? new int?(num4.GetValueOrDefault() + num5 - 1) : null);
				}
				arrayType.Dimensions.Add(new ArrayDimension(num3, upperBound));
				num2++;
			}
			return arrayType;
		}

		// Token: 0x0600021B RID: 539 RVA: 0x000131D4 File Offset: 0x000113D4
		private TypeReference GetTypeDefOrRef(MetadataToken token)
		{
			return this.reader.GetTypeDefOrRef(token);
		}

		// Token: 0x0600021C RID: 540 RVA: 0x000131F4 File Offset: 0x000113F4
		public TypeReference ReadTypeSignature()
		{
			return this.ReadTypeSignature((ElementType)base.ReadByte());
		}

		// Token: 0x0600021D RID: 541 RVA: 0x00013214 File Offset: 0x00011414
		public TypeReference ReadTypeToken()
		{
			return this.GetTypeDefOrRef(this.ReadTypeTokenSignature());
		}

		// Token: 0x0600021E RID: 542 RVA: 0x00013234 File Offset: 0x00011434
		private TypeReference ReadTypeSignature(ElementType etype)
		{
			switch (etype)
			{
			case ElementType.Void:
				return this.TypeSystem.Void;
			case ElementType.Boolean:
			case ElementType.Char:
			case ElementType.I1:
			case ElementType.U1:
			case ElementType.I2:
			case ElementType.U2:
			case ElementType.I4:
			case ElementType.U4:
			case ElementType.I8:
			case ElementType.U8:
			case ElementType.R4:
			case ElementType.R8:
			case ElementType.String:
			case (ElementType)23:
			case (ElementType)26:
				break;
			case ElementType.Ptr:
				return new PointerType(this.ReadTypeSignature());
			case ElementType.ByRef:
				return new ByReferenceType(this.ReadTypeSignature());
			case ElementType.ValueType:
			{
				TypeReference typeDefOrRef = this.GetTypeDefOrRef(this.ReadTypeTokenSignature());
				typeDefOrRef.KnownValueType();
				return typeDefOrRef;
			}
			case ElementType.Class:
				return this.GetTypeDefOrRef(this.ReadTypeTokenSignature());
			case ElementType.Var:
				return this.GetGenericParameter(GenericParameterType.Type, base.ReadCompressedUInt32());
			case ElementType.Array:
				return this.ReadArrayTypeSignature();
			case ElementType.GenericInst:
			{
				bool flag = base.ReadByte() == 17;
				TypeReference typeDefOrRef2 = this.GetTypeDefOrRef(this.ReadTypeTokenSignature());
				uint arity = base.ReadCompressedUInt32();
				GenericInstanceType genericInstanceType = new GenericInstanceType(typeDefOrRef2, (int)arity);
				this.ReadGenericInstanceSignature(typeDefOrRef2, genericInstanceType, arity);
				bool flag2 = flag;
				if (flag2)
				{
					genericInstanceType.KnownValueType();
					typeDefOrRef2.GetElementType().KnownValueType();
				}
				return genericInstanceType;
			}
			case ElementType.TypedByRef:
				return this.TypeSystem.TypedReference;
			case ElementType.I:
				return this.TypeSystem.IntPtr;
			case ElementType.U:
				return this.TypeSystem.UIntPtr;
			case ElementType.FnPtr:
			{
				FunctionPointerType functionPointerType = new FunctionPointerType();
				this.ReadMethodSignature(functionPointerType);
				return functionPointerType;
			}
			case ElementType.Object:
				return this.TypeSystem.Object;
			case ElementType.SzArray:
				return new ArrayType(this.ReadTypeSignature());
			case ElementType.MVar:
				return this.GetGenericParameter(GenericParameterType.Method, base.ReadCompressedUInt32());
			case ElementType.CModReqD:
				return new RequiredModifierType(this.GetTypeDefOrRef(this.ReadTypeTokenSignature()), this.ReadTypeSignature());
			case ElementType.CModOpt:
				return new OptionalModifierType(this.GetTypeDefOrRef(this.ReadTypeTokenSignature()), this.ReadTypeSignature());
			default:
				if (etype == ElementType.Sentinel)
				{
					return new SentinelType(this.ReadTypeSignature());
				}
				if (etype == ElementType.Pinned)
				{
					return new PinnedType(this.ReadTypeSignature());
				}
				break;
			}
			return this.GetPrimitiveType(etype);
		}

		// Token: 0x0600021F RID: 543 RVA: 0x0001349C File Offset: 0x0001169C
		public void ReadMethodSignature(IMethodSignature method)
		{
			byte b = base.ReadByte();
			bool flag = (b & 32) > 0;
			if (flag)
			{
				method.HasThis = true;
				b = (byte)((int)b & -33);
			}
			bool flag2 = (b & 64) > 0;
			if (flag2)
			{
				method.ExplicitThis = true;
				b = (byte)((int)b & -65);
			}
			method.CallingConvention = (MethodCallingConvention)b;
			MethodReference methodReference = method as MethodReference;
			bool flag3 = methodReference != null && !methodReference.DeclaringType.IsArray;
			if (flag3)
			{
				this.reader.context = methodReference;
			}
			bool flag4 = (b & 16) > 0;
			if (flag4)
			{
				uint num = base.ReadCompressedUInt32();
				bool flag5 = methodReference != null && !methodReference.IsDefinition;
				if (flag5)
				{
					SignatureReader.CheckGenericContext(methodReference, (int)(num - 1U));
				}
			}
			uint num2 = base.ReadCompressedUInt32();
			method.MethodReturnType.ReturnType = this.ReadTypeSignature();
			bool flag6 = num2 == 0U;
			if (!flag6)
			{
				MethodReference methodReference2 = method as MethodReference;
				bool flag7 = methodReference2 != null;
				Collection<ParameterDefinition> collection;
				if (flag7)
				{
					collection = (methodReference2.parameters = new ParameterDefinitionCollection(method, (int)num2));
				}
				else
				{
					collection = method.Parameters;
				}
				int num3 = 0;
				while ((long)num3 < (long)((ulong)num2))
				{
					collection.Add(new ParameterDefinition(this.ReadTypeSignature()));
					num3++;
				}
			}
		}

		// Token: 0x06000220 RID: 544 RVA: 0x000135D8 File Offset: 0x000117D8
		public object ReadConstantSignature(ElementType type)
		{
			return this.ReadPrimitiveValue(type);
		}

		// Token: 0x06000221 RID: 545 RVA: 0x000135F4 File Offset: 0x000117F4
		public void ReadCustomAttributeConstructorArguments(CustomAttribute attribute, Collection<ParameterDefinition> parameters)
		{
			int count = parameters.Count;
			bool flag = count == 0;
			if (!flag)
			{
				attribute.arguments = new Collection<CustomAttributeArgument>(count);
				for (int i = 0; i < count; i++)
				{
					TypeReference type = GenericParameterResolver.ResolveParameterTypeIfNeeded(attribute.Constructor, parameters[i]);
					attribute.arguments.Add(this.ReadCustomAttributeFixedArgument(type));
				}
			}
		}

		// Token: 0x06000222 RID: 546 RVA: 0x0001365C File Offset: 0x0001185C
		private CustomAttributeArgument ReadCustomAttributeFixedArgument(TypeReference type)
		{
			bool isArray = type.IsArray;
			CustomAttributeArgument result;
			if (isArray)
			{
				result = this.ReadCustomAttributeFixedArrayArgument((ArrayType)type);
			}
			else
			{
				result = this.ReadCustomAttributeElement(type);
			}
			return result;
		}

		// Token: 0x06000223 RID: 547 RVA: 0x00013690 File Offset: 0x00011890
		public void ReadCustomAttributeNamedArguments(ushort count, ref Collection<CustomAttributeNamedArgument> fields, ref Collection<CustomAttributeNamedArgument> properties)
		{
			for (int i = 0; i < (int)count; i++)
			{
				bool flag = !this.CanReadMore();
				if (flag)
				{
					break;
				}
				this.ReadCustomAttributeNamedArgument(ref fields, ref properties);
			}
		}

		// Token: 0x06000224 RID: 548 RVA: 0x000136C8 File Offset: 0x000118C8
		private void ReadCustomAttributeNamedArgument(ref Collection<CustomAttributeNamedArgument> fields, ref Collection<CustomAttributeNamedArgument> properties)
		{
			byte b = base.ReadByte();
			TypeReference type = this.ReadCustomAttributeFieldOrPropType();
			string name = this.ReadUTF8String();
			byte b2 = b;
			byte b3 = b2;
			Collection<CustomAttributeNamedArgument> customAttributeNamedArgumentCollection;
			if (b3 != 83)
			{
				if (b3 != 84)
				{
					throw new NotSupportedException();
				}
				customAttributeNamedArgumentCollection = SignatureReader.GetCustomAttributeNamedArgumentCollection(ref properties);
			}
			else
			{
				customAttributeNamedArgumentCollection = SignatureReader.GetCustomAttributeNamedArgumentCollection(ref fields);
			}
			customAttributeNamedArgumentCollection.Add(new CustomAttributeNamedArgument(name, this.ReadCustomAttributeFixedArgument(type)));
		}

		// Token: 0x06000225 RID: 549 RVA: 0x00013730 File Offset: 0x00011930
		private static Collection<CustomAttributeNamedArgument> GetCustomAttributeNamedArgumentCollection(ref Collection<CustomAttributeNamedArgument> collection)
		{
			bool flag = collection != null;
			Collection<CustomAttributeNamedArgument> result;
			if (flag)
			{
				result = collection;
			}
			else
			{
				Collection<CustomAttributeNamedArgument> collection2;
				collection = (collection2 = new Collection<CustomAttributeNamedArgument>());
				result = collection2;
			}
			return result;
		}

		// Token: 0x06000226 RID: 550 RVA: 0x0001375C File Offset: 0x0001195C
		private CustomAttributeArgument ReadCustomAttributeFixedArrayArgument(ArrayType type)
		{
			uint num = base.ReadUInt32();
			bool flag = num == uint.MaxValue;
			CustomAttributeArgument result;
			if (flag)
			{
				result = new CustomAttributeArgument(type, null);
			}
			else
			{
				bool flag2 = num == 0U;
				if (flag2)
				{
					result = new CustomAttributeArgument(type, Empty<CustomAttributeArgument>.Array);
				}
				else
				{
					CustomAttributeArgument[] array = new CustomAttributeArgument[num];
					TypeReference elementType = type.ElementType;
					int num2 = 0;
					while ((long)num2 < (long)((ulong)num))
					{
						array[num2] = this.ReadCustomAttributeElement(elementType);
						num2++;
					}
					result = new CustomAttributeArgument(type, array);
				}
			}
			return result;
		}

		// Token: 0x06000227 RID: 551 RVA: 0x000137E0 File Offset: 0x000119E0
		private CustomAttributeArgument ReadCustomAttributeElement(TypeReference type)
		{
			bool isArray = type.IsArray;
			CustomAttributeArgument result;
			if (isArray)
			{
				result = this.ReadCustomAttributeFixedArrayArgument((ArrayType)type);
			}
			else
			{
				result = new CustomAttributeArgument(type, (type.etype == ElementType.Object) ? this.ReadCustomAttributeElement(this.ReadCustomAttributeFieldOrPropType()) : this.ReadCustomAttributeElementValue(type));
			}
			return result;
		}

		// Token: 0x06000228 RID: 552 RVA: 0x00013838 File Offset: 0x00011A38
		private object ReadCustomAttributeElementValue(TypeReference type)
		{
			ElementType etype = type.etype;
			bool flag = etype == ElementType.GenericInst;
			if (flag)
			{
				type = type.GetElementType();
				etype = type.etype;
			}
			ElementType elementType = etype;
			ElementType elementType2 = elementType;
			object result;
			if (elementType2 != ElementType.None)
			{
				if (elementType2 != ElementType.String)
				{
					result = this.ReadPrimitiveValue(etype);
				}
				else
				{
					result = this.ReadUTF8String();
				}
			}
			else
			{
				bool flag2 = type.IsTypeOf("System", "Type");
				if (flag2)
				{
					result = this.ReadTypeReference();
				}
				else
				{
					result = this.ReadCustomAttributeEnum(type);
				}
			}
			return result;
		}

		// Token: 0x06000229 RID: 553 RVA: 0x000138BC File Offset: 0x00011ABC
		private object ReadPrimitiveValue(ElementType type)
		{
			object result;
			switch (type)
			{
			case ElementType.Boolean:
				result = (base.ReadByte() == 1);
				break;
			case ElementType.Char:
				result = (char)base.ReadUInt16();
				break;
			case ElementType.I1:
				result = (sbyte)base.ReadByte();
				break;
			case ElementType.U1:
				result = base.ReadByte();
				break;
			case ElementType.I2:
				result = base.ReadInt16();
				break;
			case ElementType.U2:
				result = base.ReadUInt16();
				break;
			case ElementType.I4:
				result = base.ReadInt32();
				break;
			case ElementType.U4:
				result = base.ReadUInt32();
				break;
			case ElementType.I8:
				result = base.ReadInt64();
				break;
			case ElementType.U8:
				result = base.ReadUInt64();
				break;
			case ElementType.R4:
				result = base.ReadSingle();
				break;
			case ElementType.R8:
				result = base.ReadDouble();
				break;
			default:
				throw new NotImplementedException(type.ToString());
			}
			return result;
		}

		// Token: 0x0600022A RID: 554 RVA: 0x000139D8 File Offset: 0x00011BD8
		private TypeReference GetPrimitiveType(ElementType etype)
		{
			TypeReference result;
			switch (etype)
			{
			case ElementType.Boolean:
				result = this.TypeSystem.Boolean;
				break;
			case ElementType.Char:
				result = this.TypeSystem.Char;
				break;
			case ElementType.I1:
				result = this.TypeSystem.SByte;
				break;
			case ElementType.U1:
				result = this.TypeSystem.Byte;
				break;
			case ElementType.I2:
				result = this.TypeSystem.Int16;
				break;
			case ElementType.U2:
				result = this.TypeSystem.UInt16;
				break;
			case ElementType.I4:
				result = this.TypeSystem.Int32;
				break;
			case ElementType.U4:
				result = this.TypeSystem.UInt32;
				break;
			case ElementType.I8:
				result = this.TypeSystem.Int64;
				break;
			case ElementType.U8:
				result = this.TypeSystem.UInt64;
				break;
			case ElementType.R4:
				result = this.TypeSystem.Single;
				break;
			case ElementType.R8:
				result = this.TypeSystem.Double;
				break;
			case ElementType.String:
				result = this.TypeSystem.String;
				break;
			default:
				throw new NotImplementedException(etype.ToString());
			}
			return result;
		}

		// Token: 0x0600022B RID: 555 RVA: 0x00013B04 File Offset: 0x00011D04
		private TypeReference ReadCustomAttributeFieldOrPropType()
		{
			ElementType elementType = (ElementType)base.ReadByte();
			ElementType elementType2 = elementType;
			ElementType elementType3 = elementType2;
			if (elementType3 <= ElementType.Type)
			{
				if (elementType3 == ElementType.SzArray)
				{
					return new ArrayType(this.ReadCustomAttributeFieldOrPropType());
				}
				if (elementType3 == ElementType.Type)
				{
					return this.TypeSystem.LookupType("System", "Type");
				}
			}
			else
			{
				if (elementType3 == ElementType.Boxed)
				{
					return this.TypeSystem.Object;
				}
				if (elementType3 == ElementType.Enum)
				{
					return this.ReadTypeReference();
				}
			}
			return this.GetPrimitiveType(elementType);
		}

		// Token: 0x0600022C RID: 556 RVA: 0x00013B88 File Offset: 0x00011D88
		public TypeReference ReadTypeReference()
		{
			return TypeParser.ParseType(this.reader.module, this.ReadUTF8String(), false);
		}

		// Token: 0x0600022D RID: 557 RVA: 0x00013BB4 File Offset: 0x00011DB4
		private object ReadCustomAttributeEnum(TypeReference enum_type)
		{
			TypeDefinition typeDefinition = enum_type.CheckedResolve();
			bool flag = !typeDefinition.IsEnum;
			if (flag)
			{
				throw new ArgumentException();
			}
			return this.ReadCustomAttributeElementValue(typeDefinition.GetEnumUnderlyingType());
		}

		// Token: 0x0600022E RID: 558 RVA: 0x00013BEC File Offset: 0x00011DEC
		public SecurityAttribute ReadSecurityAttribute()
		{
			SecurityAttribute securityAttribute = new SecurityAttribute(this.ReadTypeReference());
			base.ReadCompressedUInt32();
			this.ReadCustomAttributeNamedArguments((ushort)base.ReadCompressedUInt32(), ref securityAttribute.fields, ref securityAttribute.properties);
			return securityAttribute;
		}

		// Token: 0x0600022F RID: 559 RVA: 0x00013C2C File Offset: 0x00011E2C
		public MarshalInfo ReadMarshalInfo()
		{
			NativeType nativeType = this.ReadNativeType();
			NativeType nativeType2 = nativeType;
			NativeType nativeType3 = nativeType2;
			if (nativeType3 <= NativeType.SafeArray)
			{
				if (nativeType3 == NativeType.FixedSysString)
				{
					FixedSysStringMarshalInfo fixedSysStringMarshalInfo = new FixedSysStringMarshalInfo();
					bool flag = this.CanReadMore();
					if (flag)
					{
						fixedSysStringMarshalInfo.size = (int)base.ReadCompressedUInt32();
					}
					return fixedSysStringMarshalInfo;
				}
				if (nativeType3 == NativeType.SafeArray)
				{
					SafeArrayMarshalInfo safeArrayMarshalInfo = new SafeArrayMarshalInfo();
					bool flag2 = this.CanReadMore();
					if (flag2)
					{
						safeArrayMarshalInfo.element_type = this.ReadVariantType();
					}
					return safeArrayMarshalInfo;
				}
			}
			else
			{
				if (nativeType3 == NativeType.FixedArray)
				{
					FixedArrayMarshalInfo fixedArrayMarshalInfo = new FixedArrayMarshalInfo();
					bool flag3 = this.CanReadMore();
					if (flag3)
					{
						fixedArrayMarshalInfo.size = (int)base.ReadCompressedUInt32();
					}
					bool flag4 = this.CanReadMore();
					if (flag4)
					{
						fixedArrayMarshalInfo.element_type = this.ReadNativeType();
					}
					return fixedArrayMarshalInfo;
				}
				if (nativeType3 == NativeType.Array)
				{
					ArrayMarshalInfo arrayMarshalInfo = new ArrayMarshalInfo();
					bool flag5 = this.CanReadMore();
					if (flag5)
					{
						arrayMarshalInfo.element_type = this.ReadNativeType();
					}
					bool flag6 = this.CanReadMore();
					if (flag6)
					{
						arrayMarshalInfo.size_parameter_index = (int)base.ReadCompressedUInt32();
					}
					bool flag7 = this.CanReadMore();
					if (flag7)
					{
						arrayMarshalInfo.size = (int)base.ReadCompressedUInt32();
					}
					bool flag8 = this.CanReadMore();
					if (flag8)
					{
						arrayMarshalInfo.size_parameter_multiplier = (int)base.ReadCompressedUInt32();
					}
					return arrayMarshalInfo;
				}
				if (nativeType3 == NativeType.CustomMarshaler)
				{
					CustomMarshalInfo customMarshalInfo = new CustomMarshalInfo();
					string text = this.ReadUTF8String();
					customMarshalInfo.guid = ((!string.IsNullOrEmpty(text)) ? new Guid(text) : Guid.Empty);
					customMarshalInfo.unmanaged_type = this.ReadUTF8String();
					customMarshalInfo.managed_type = this.ReadTypeReference();
					customMarshalInfo.cookie = this.ReadUTF8String();
					return customMarshalInfo;
				}
			}
			return new MarshalInfo(nativeType);
		}

		// Token: 0x06000230 RID: 560 RVA: 0x00013DEC File Offset: 0x00011FEC
		private NativeType ReadNativeType()
		{
			return (NativeType)base.ReadByte();
		}

		// Token: 0x06000231 RID: 561 RVA: 0x00013E04 File Offset: 0x00012004
		private VariantType ReadVariantType()
		{
			return (VariantType)base.ReadByte();
		}

		// Token: 0x06000232 RID: 562 RVA: 0x00013E1C File Offset: 0x0001201C
		private string ReadUTF8String()
		{
			bool flag = this.buffer[this.position] == byte.MaxValue;
			string result;
			if (flag)
			{
				this.position++;
				result = null;
			}
			else
			{
				int num = (int)base.ReadCompressedUInt32();
				bool flag2 = num == 0;
				if (flag2)
				{
					result = string.Empty;
				}
				else
				{
					bool flag3 = this.position + num > this.buffer.Length;
					if (flag3)
					{
						result = string.Empty;
					}
					else
					{
						string @string = Encoding.UTF8.GetString(this.buffer, this.position, num);
						this.position += num;
						result = @string;
					}
				}
			}
			return result;
		}

		// Token: 0x06000233 RID: 563 RVA: 0x00013EBC File Offset: 0x000120BC
		public string ReadDocumentName()
		{
			char c = (char)this.buffer[this.position];
			this.position++;
			StringBuilder stringBuilder = new StringBuilder();
			int num = 0;
			while (this.CanReadMore())
			{
				bool flag = num > 0 && c > '\0';
				if (flag)
				{
					stringBuilder.Append(c);
				}
				uint num2 = base.ReadCompressedUInt32();
				bool flag2 = num2 > 0U;
				if (flag2)
				{
					stringBuilder.Append(this.reader.ReadUTF8StringBlob(num2));
				}
				num++;
			}
			return stringBuilder.ToString();
		}

		// Token: 0x06000234 RID: 564 RVA: 0x00013F4C File Offset: 0x0001214C
		public Collection<SequencePoint> ReadSequencePoints(Document document)
		{
			base.ReadCompressedUInt32();
			bool flag = document == null;
			if (flag)
			{
				document = this.reader.GetDocument(base.ReadCompressedUInt32());
			}
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			bool flag2 = true;
			long num4 = (long)((ulong)this.sig_length - (ulong)((long)this.position - (long)((ulong)this.start)));
			int capacity = (int)num4 / 5;
			Collection<SequencePoint> collection = new Collection<SequencePoint>(capacity);
			int num5 = 0;
			while (this.CanReadMore())
			{
				int num6 = (int)base.ReadCompressedUInt32();
				bool flag3 = num5 > 0 && num6 == 0;
				if (flag3)
				{
					document = this.reader.GetDocument(base.ReadCompressedUInt32());
				}
				else
				{
					num += num6;
					int num7 = (int)base.ReadCompressedUInt32();
					int num8 = (int)((num7 == 0) ? base.ReadCompressedUInt32() : ((uint)base.ReadCompressedInt32()));
					bool flag4 = num7 == 0 && num8 == 0;
					if (flag4)
					{
						collection.Add(new SequencePoint(num, document)
						{
							StartLine = 16707566,
							EndLine = 16707566,
							StartColumn = 0,
							EndColumn = 0
						});
					}
					else
					{
						bool flag5 = flag2;
						if (flag5)
						{
							num2 = (int)base.ReadCompressedUInt32();
							num3 = (int)base.ReadCompressedUInt32();
						}
						else
						{
							num2 += base.ReadCompressedInt32();
							num3 += base.ReadCompressedInt32();
						}
						collection.Add(new SequencePoint(num, document)
						{
							StartLine = num2,
							StartColumn = num3,
							EndLine = num2 + num7,
							EndColumn = num3 + num8
						});
						flag2 = false;
					}
				}
				num5++;
			}
			return collection;
		}

		// Token: 0x06000235 RID: 565 RVA: 0x000140DC File Offset: 0x000122DC
		public bool CanReadMore()
		{
			return (long)this.position - (long)((ulong)this.start) < (long)((ulong)this.sig_length);
		}

		// Token: 0x0400008D RID: 141
		private readonly MetadataReader reader;

		// Token: 0x0400008E RID: 142
		internal readonly uint start;

		// Token: 0x0400008F RID: 143
		internal readonly uint sig_length;
	}
}
